/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.cr.cR.CRFunction;
import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.CalcCR;
import org.xtext.example.cr.cR.CalcMean;
import org.xtext.example.cr.cR.FindSimilar;
import org.xtext.example.cr.cR.HighestCR;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Function</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.CRFunctionImpl#getCalcCR <em>Calc CR</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.CRFunctionImpl#getCalcMean <em>Calc Mean</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.CRFunctionImpl#getHighestCR <em>Highest CR</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.CRFunctionImpl#getFindSimilar <em>Find Similar</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CRFunctionImpl extends MinimalEObjectImpl.Container implements CRFunction
{
  /**
   * The cached value of the '{@link #getCalcCR() <em>Calc CR</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCalcCR()
   * @generated
   * @ordered
   */
  protected CalcCR calcCR;

  /**
   * The cached value of the '{@link #getCalcMean() <em>Calc Mean</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCalcMean()
   * @generated
   * @ordered
   */
  protected CalcMean calcMean;

  /**
   * The cached value of the '{@link #getHighestCR() <em>Highest CR</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHighestCR()
   * @generated
   * @ordered
   */
  protected HighestCR highestCR;

  /**
   * The cached value of the '{@link #getFindSimilar() <em>Find Similar</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFindSimilar()
   * @generated
   * @ordered
   */
  protected FindSimilar findSimilar;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected CRFunctionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.CR_FUNCTION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CalcCR getCalcCR()
  {
    return calcCR;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetCalcCR(CalcCR newCalcCR, NotificationChain msgs)
  {
    CalcCR oldCalcCR = calcCR;
    calcCR = newCalcCR;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.CR_FUNCTION__CALC_CR, oldCalcCR, newCalcCR);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCalcCR(CalcCR newCalcCR)
  {
    if (newCalcCR != calcCR)
    {
      NotificationChain msgs = null;
      if (calcCR != null)
        msgs = ((InternalEObject)calcCR).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.CR_FUNCTION__CALC_CR, null, msgs);
      if (newCalcCR != null)
        msgs = ((InternalEObject)newCalcCR).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.CR_FUNCTION__CALC_CR, null, msgs);
      msgs = basicSetCalcCR(newCalcCR, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.CR_FUNCTION__CALC_CR, newCalcCR, newCalcCR));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CalcMean getCalcMean()
  {
    return calcMean;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetCalcMean(CalcMean newCalcMean, NotificationChain msgs)
  {
    CalcMean oldCalcMean = calcMean;
    calcMean = newCalcMean;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.CR_FUNCTION__CALC_MEAN, oldCalcMean, newCalcMean);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCalcMean(CalcMean newCalcMean)
  {
    if (newCalcMean != calcMean)
    {
      NotificationChain msgs = null;
      if (calcMean != null)
        msgs = ((InternalEObject)calcMean).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.CR_FUNCTION__CALC_MEAN, null, msgs);
      if (newCalcMean != null)
        msgs = ((InternalEObject)newCalcMean).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.CR_FUNCTION__CALC_MEAN, null, msgs);
      msgs = basicSetCalcMean(newCalcMean, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.CR_FUNCTION__CALC_MEAN, newCalcMean, newCalcMean));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public HighestCR getHighestCR()
  {
    return highestCR;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetHighestCR(HighestCR newHighestCR, NotificationChain msgs)
  {
    HighestCR oldHighestCR = highestCR;
    highestCR = newHighestCR;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.CR_FUNCTION__HIGHEST_CR, oldHighestCR, newHighestCR);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setHighestCR(HighestCR newHighestCR)
  {
    if (newHighestCR != highestCR)
    {
      NotificationChain msgs = null;
      if (highestCR != null)
        msgs = ((InternalEObject)highestCR).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.CR_FUNCTION__HIGHEST_CR, null, msgs);
      if (newHighestCR != null)
        msgs = ((InternalEObject)newHighestCR).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.CR_FUNCTION__HIGHEST_CR, null, msgs);
      msgs = basicSetHighestCR(newHighestCR, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.CR_FUNCTION__HIGHEST_CR, newHighestCR, newHighestCR));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FindSimilar getFindSimilar()
  {
    return findSimilar;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetFindSimilar(FindSimilar newFindSimilar, NotificationChain msgs)
  {
    FindSimilar oldFindSimilar = findSimilar;
    findSimilar = newFindSimilar;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.CR_FUNCTION__FIND_SIMILAR, oldFindSimilar, newFindSimilar);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFindSimilar(FindSimilar newFindSimilar)
  {
    if (newFindSimilar != findSimilar)
    {
      NotificationChain msgs = null;
      if (findSimilar != null)
        msgs = ((InternalEObject)findSimilar).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.CR_FUNCTION__FIND_SIMILAR, null, msgs);
      if (newFindSimilar != null)
        msgs = ((InternalEObject)newFindSimilar).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.CR_FUNCTION__FIND_SIMILAR, null, msgs);
      msgs = basicSetFindSimilar(newFindSimilar, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.CR_FUNCTION__FIND_SIMILAR, newFindSimilar, newFindSimilar));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.CR_FUNCTION__CALC_CR:
        return basicSetCalcCR(null, msgs);
      case CRPackage.CR_FUNCTION__CALC_MEAN:
        return basicSetCalcMean(null, msgs);
      case CRPackage.CR_FUNCTION__HIGHEST_CR:
        return basicSetHighestCR(null, msgs);
      case CRPackage.CR_FUNCTION__FIND_SIMILAR:
        return basicSetFindSimilar(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.CR_FUNCTION__CALC_CR:
        return getCalcCR();
      case CRPackage.CR_FUNCTION__CALC_MEAN:
        return getCalcMean();
      case CRPackage.CR_FUNCTION__HIGHEST_CR:
        return getHighestCR();
      case CRPackage.CR_FUNCTION__FIND_SIMILAR:
        return getFindSimilar();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.CR_FUNCTION__CALC_CR:
        setCalcCR((CalcCR)newValue);
        return;
      case CRPackage.CR_FUNCTION__CALC_MEAN:
        setCalcMean((CalcMean)newValue);
        return;
      case CRPackage.CR_FUNCTION__HIGHEST_CR:
        setHighestCR((HighestCR)newValue);
        return;
      case CRPackage.CR_FUNCTION__FIND_SIMILAR:
        setFindSimilar((FindSimilar)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.CR_FUNCTION__CALC_CR:
        setCalcCR((CalcCR)null);
        return;
      case CRPackage.CR_FUNCTION__CALC_MEAN:
        setCalcMean((CalcMean)null);
        return;
      case CRPackage.CR_FUNCTION__HIGHEST_CR:
        setHighestCR((HighestCR)null);
        return;
      case CRPackage.CR_FUNCTION__FIND_SIMILAR:
        setFindSimilar((FindSimilar)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.CR_FUNCTION__CALC_CR:
        return calcCR != null;
      case CRPackage.CR_FUNCTION__CALC_MEAN:
        return calcMean != null;
      case CRPackage.CR_FUNCTION__HIGHEST_CR:
        return highestCR != null;
      case CRPackage.CR_FUNCTION__FIND_SIMILAR:
        return findSimilar != null;
    }
    return super.eIsSet(featureID);
  }

} //CRFunctionImpl
